﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Audio;

namespace PloobsEngine.Audio
{
    /// <summary>
    /// SoundEffect MusicPlayer
    /// </summary>
    public static class SoundEffectAudioPlayer
    {
        private static Dictionary<string, SimpleSoundEffect> musics = new Dictionary<string, SimpleSoundEffect>();
        
        public static void PlayEffect(string musicName)
        {
            musics[musicName].Play();            
        }

        public static void PauseEffect(string musicName)
        {
            musics[musicName].Pause();
        }

        public static void Resume(string musicName)
        {
            musics[musicName].Resume();
        }

        public static SoundState SoundState(string musicName)
        {
            return musics[musicName].State; 
        }
             
        
        /// <summary>
        /// Add A Sound Effect to the Repo
        /// </summary>
        /// <param name="musicNamePath">filepath</param>
        /// <param name="musicName">Name used to refer to this effect latter</param>
        /// <param name="volume">between 0 - 1</param>
        /// <param name="pitch">between -1 to 1 (octaves) </param>
        /// <param name="pan">between -1 to 1 (left - right)</param>
        /// <param name="isLooped"></param>
        public static void AddEffectToRepository(string musicNamePath, String musicName, float volume, float pitch, float pan,bool isLooped)
        {
            SimpleSoundEffect sse = new SimpleSoundEffect(musicNamePath, volume, pitch, pan, isLooped);
            musics.Add(musicName, sse);
        }

        public static void RemoveEffectFromRepository(string musicName)
        {
            musics.Remove(musicName);
        }        

        

    }
}
